package maze;

/**
 * Created by Роман on 01.05.14.
 */
public class Cell {
    private boolean upWall;
    private boolean downWall;
    private boolean leftWall;
    private boolean rightWall;
    enum content {dart, poisonDart, trap, stick, key, treasure, empty}
    private content object;
    private int mazeSet;
    enum exitType {wood, metal, stone, gold, none}
    enum exitPos {left, right, up, down, none}
    private exitPos doorPos;
    private exitType door;
    private exitType key;

    public Cell()
    {
        this.upWall = false;
        this.downWall = false;
        this.leftWall = false;
        this.rightWall = false;
        this.object = content.empty;
        this.mazeSet = 0;
        this.door = exitType.none;
        this.key = exitType.none;
        this.doorPos = exitPos.none;
    }

    public void setWall(int type, boolean value)
    {
        switch (type)
        {
            case 1://up [left]
            {
                this.upWall = value;
                break;
            }
            case 2://down [right]
            {
                this.downWall = value;
                break;
            }
            case 3://left [up]
            {
                this.leftWall = value;
                break;
            }
            case 4://right [down]
            {
                this.rightWall = value;
                break;
            }
            default:
                return;
        }
    }

    public void setContent(String value)
    {
        object = content.valueOf(value);
    }

    public void setDoorPos(int value)
    {
        switch(value)
        {
            case 0://left
            {
                this.doorPos = exitPos.left;
                break;
            }
            case 1://right
            {
                this.doorPos = exitPos.right;
                break;
            }
            case 2://up
            {
                this.doorPos = exitPos.up;
                break;
            }
            case 3://down
            {
                this.doorPos = exitPos.down;
                break;
            }
            default:
            {
                this.doorPos = exitPos.none;
                break;
            }
        }
    }

    public void setMazeSet(int set)
    {
        this.mazeSet = set;
    }

    public void setDoorType(int value)
    {
        switch(value)
        {
            case 0:
            {
                this.door = exitType.wood;
                break;
            }
            case 1:
            {
                this.door = exitType.metal;
                break;
            }
            case 2:
            {
                this.door = exitType.stone;
                break;
            }
            case 3:
            {
                this.door = exitType.gold;
                break;
            }
            default:
            {
                this.door = exitType.none;
                break;
            }
        }
    }

    public void setKeyType(int value)
    {
        switch(value)
        {
            case 0:
            {
                this.key = exitType.wood;
                break;
            }
            case 1:
            {
                this.key = exitType.metal;
                break;
            }
            case 2:
            {
                this.key = exitType.stone;
                break;
            }
            case 3:
            {
                this.key = exitType.gold;
                break;
            }
            default:
            {
                this.key = exitType.none;
                break;
            }
        }
    }

    public String getDoorType()
    {
        return this.door.toString();
    }

    public String getDoorPos()
    {
        return this.doorPos.toString();
    }

    public String getKeyType()
    {
        return this.key.toString();
    }

    public boolean getWall(int type)
    {
        switch (type)
        {
            case 1://up
            {
                return this.upWall;
            }
            case 2://down
            {
                return this.downWall;
            }
            case 3://left
            {
                return  this.leftWall;
            }
            case 4://right
            {
                return this.rightWall;
            }
            default:
                return false;
        }
    }

    public String getContent()
    {
        return this.object.toString();
    }
    public int getMazeSet()
    {
        return this.mazeSet;
    }
}
